var express = require('express')
// var fs = require('fs')
// var path=require('path')
//创建子路由对象(用来管理一部分后端路由)
var userRouter = express.Router()


//登陆
var arr=[{id:18893035778,pass:1234}]
userRouter.post( '/login', (req,res)=>{
    var {id,pass} = req.body;
    var i = arr.findIndex((item)=>{
        return item.id == id && item.pass == pass;
    })

    //如果i不是-1, 说明来自客户端的数据是合法的.
    if( i != -1 ){
        res.send( {code:200, msg:'登陆成功!',userinfo: arr[i]} );
    }else{
        res.send( {code:400, msg:'登陆失败!'} );
    }
} )
module.exports = userRouter;